package com.ximmerse.chengdon;

import org.testng.annotations.Test;
import com.aventstack.extentreports.ExtentReports;
import com.aventstack.extentreports.ExtentTest;
import com.aventstack.extentreports.Status;

import Sql.mysql;
import initAll.TestNGListener;
import initAll.eventsListener;
import initAll.getWebDriver;
import initAll.login;
import initAll.login2;
import javaUnit.ThreadTime;
import seleniumUnit.linkOperate;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Parameters;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;

import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.concurrent.TimeUnit;

import org.apache.commons.lang3.time.StopWatch;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.events.EventFiringWebDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.ITestResult;
import org.testng.annotations.AfterClass;

@Test
public class homePageLogin {
	private static WebDriver driver;
	private static String url = "http://10.168.1.250:9080/";
	private static login login;
	private static final Logger log = LogManager.getLogger(homePageLogin.class.getName());
	ExtentReports report = TestNGListener.report;
	ExtentTest test = TestNGListener.test;
	linkOperate Operate;
	public static double sum_homepage=0.0,sum_login=0.0,sum_userTime=0.0,sum_roleTime=0.0,sum_gameTime=0.0,sum_devicesTime=0.0,sum_deptTime=0.0,sum_opuserTime=0.0,sum_upVersion=0.0,sum_logRunDeviceTime=0.0,sum_logDeviceExTime=0.0,sum_startGameTime=0.0,sum_endGameTime=0.0,sum_gameRunTime=0.0,sum_gameplaysTime=0.0,
			sum_gameEXTime=0.0,sum_gameEventTime=0.0,sum_purchaseTime=0.0,sum_consumeTime=0.0,sum_giveTime=0.0,sum_cityTime=0.0,sum_dictProductTime=0.0,sum_dictVersionTime=0.0;
	StopWatch watch = new StopWatch();

	//用户登录-退出
	@Parameters({ "browser" })
	public void login_out(String browser) {
		WebDriverWait wait = new WebDriverWait(driver, 15);
		watch.start();
		driver.get(url);
		test.log(Status.INFO, "当前URL="+driver.getCurrentUrl());
		wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("/html/body/section/div[1]/div/div[2]/form/div[4]/div/button")));
		double homepage=(double) watch.getTime() / 1000.0;
		watch.reset();
		sum_homepage = sum_homepage+homepage;
		test.log(Status.INFO, "首页加载,当前URL="+driver.getCurrentUrl()+",loadingTime="+homepage+"s");
		ThreadTime.sleepTime(1);
		report.flush();

		//输入用户名和密码
		mysql my = new mysql("resource/creaeDatabaseAndTable.xml");
		ArrayList<String> ls=new ArrayList<String>();
		try {
			ls = my.otherCustomCmd("SELECT CODE FROM `captcha_code` ORDER BY id DESc LIMIT 1");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		login.inputUserInfo("admin","123456",ls.get(0).replace(" ", ""));
		test.log(Status.INFO, "	输入用户名密码");
		watch.start();
		//点击登陆
		login.clickBtnLogin();
		test.log(Status.INFO, "	点击登陆按钮");
		wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("/html/body/section/div[2]/div/div/div[1]/div[2]/div/div/div")));
		double loginTime=(double) watch.getTime() / 1000.0;
		watch.reset();
		sum_login = sum_login+loginTime;
		test.log(Status.INFO, "首页加载,当前URL="+driver.getCurrentUrl()+",loadingTime="+loginTime+"s");
		ThreadTime.sleepTime(1);
		report.flush();

		
		//打开系统管理子菜单
		login.table_systemClick(true);
		test.log(Status.INFO, "点击系统管理，打开系统管理子菜单");
		ThreadTime.sleepTime(1);

		//用户管理
		watch.start();
		login.table_userClick();
		wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("/html/body/section/div[2]/div/div/div[2]/div/div/div/div/div[2]/div[1]/div[3]/table/tbody/tr[1]/td[2]/div")));
		double userTime=(double) watch.getTime() / 1000.0;
		watch.reset();
		sum_userTime = sum_userTime+userTime;
		test.log(Status.INFO, "点击用户管理");
		test.log(Status.INFO, "用户管理,当前URL="+driver.getCurrentUrl()+",loadingTime="+userTime+"s");
		ThreadTime.sleepTime(1);
			
		//角色管理
		watch.start();
		login.table_roleClick();
		wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("/html/body/section/div[2]/div/div/div[2]/div/div/div/div/div[2]/div[1]/div[3]/table/tbody/tr[1]/td[1]/div")));
		double roleTime=(double) watch.getTime() / 1000.0;
		watch.reset();
		sum_roleTime = sum_roleTime+roleTime;
		test.log(Status.INFO, "点击角色管理");
		test.log(Status.INFO, "角色管理,当前URL="+driver.getCurrentUrl()+",loadingTime="+roleTime+"s");
		ThreadTime.sleepTime(1);
			
		//关闭系统管理子菜单
		login.table_systemClick(false);
		test.log(Status.INFO, "点击系统管理，关闭系统管理子菜单");
		report.flush();

		
		//打开教学内容和设备信息的子菜单
		login.table_gameClick(true);
		ThreadTime.sleepTime(1);
		test.log(Status.INFO, "点击内容管理，打开教学内容子菜单");
		
		//内容管理
		watch.start();
		login.table_gameLSClick();
		wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("/html/body/section/div[2]/div/div/div[2]/div/div/div/div/div[2]/div[1]/div[3]/table/tbody/tr[1]/td[2]/div")));
		double gameTime=(double) watch.getTime() / 1000.0;
		watch.reset();
		sum_gameTime = sum_gameTime+gameTime;
		test.log(Status.INFO, "点击内容管理");
		test.log(Status.INFO, "内容管理,当前URL="+driver.getCurrentUrl()+",loadingTime="+gameTime+"s");
		ThreadTime.sleepTime(1);
		
		//关闭内容管理子菜单
		login.table_gameClick(false);
		ThreadTime.sleepTime(1);
		test.log(Status.INFO, "点击内容管理，关闭教学内容子菜单");
		report.flush();
		
		//设备管理
		login.table_devicesClick(true);
		ThreadTime.sleepTime(1);
		test.log(Status.INFO, "点击设备管理，打开设备管理子菜单");	
		
		//设备管理
		watch.start();
		login.table_devicesInfoClick();
		wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("/html/body/section/div[2]/div/div/div[2]/div/div/div/div/div[2]/div[1]/div[3]/table/tbody/tr[1]/td[2]/div")));
		double devicesTime=(double) watch.getTime() / 1000.0;
		watch.reset();
		sum_devicesTime = sum_devicesTime+devicesTime;
		test.log(Status.INFO, "点击设备管理");
		test.log(Status.INFO, "设备管理,当前URL="+driver.getCurrentUrl()+",loadingTime="+devicesTime+"s");
		ThreadTime.sleepTime(1);

		//关闭设备管理子菜单
		login.table_devicesClick(false);
		ThreadTime.sleepTime(1);
		test.log(Status.INFO, "点击设备管理，关闭设备管理子菜单");
		report.flush();
		
		//教室的子菜单
		login.table_deptClick(true);
		ThreadTime.sleepTime(1);
		test.log(Status.INFO, "点击教室管理，打开教室管理子菜单");
		//教室管理
		watch.start();
		login.table_deptsClick();
		wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("/html/body/section/div[2]/div/div/div[2]/div/div/div/div/div[1]/div[2]/div[1]/div[3]/table/tbody/tr[1]/td[2]/div")));
		double deptTime=(double) watch.getTime() / 1000.0;
		watch.reset();
		sum_deptTime = sum_deptTime+deptTime;
		test.log(Status.INFO, "点击教室管理");
		test.log(Status.INFO, "教室管理,当前URL="+driver.getCurrentUrl()+",loadingTime="+deptTime+"s");
		ThreadTime.sleepTime(1);
		
		//教室账号管理
		watch.start();
		login.table_opuserClick();
		wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("/html/body/section/div[2]/div/div/div[2]/div/div/div/div/div[2]/div[1]/div[3]/table/tbody/tr/td[2]/div")));
		double opuserTime=(double) watch.getTime() / 1000.0;
		watch.reset();
		sum_opuserTime = sum_opuserTime+opuserTime;
		test.log(Status.INFO, "点击教室账号管理");
		test.log(Status.INFO, "教室账号管理,当前URL="+driver.getCurrentUrl()+",loadingTime="+opuserTime+"s");
		ThreadTime.sleepTime(1);
		
		//关闭教室管理子菜单
		login.table_deptClick(false);
		ThreadTime.sleepTime(1);
		test.log(Status.INFO, "点击教室管理，关闭教室管理子菜单");
		report.flush();
		
		//版本的子菜单
		login.table_versionClick(true);
		ThreadTime.sleepTime(1);
		test.log(Status.INFO, "点击版本管理，打开版本管理子菜单");

		//版本上传
		watch.start();
		login.table_upversionClick();
		wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("/html/body/section/div[2]/div/div/div[2]/div/div/div/div/div[2]/div[1]/div[3]/table/tbody/tr/td[2]")));
		double upVersionTime=(double) watch.getTime() / 1000.0;
		watch.reset();
		sum_upVersion = sum_upVersion+upVersionTime;
		test.log(Status.INFO, "点击版本上传");
		test.log(Status.INFO, "版本上传,当前URL="+driver.getCurrentUrl()+",loadingTime="+upVersionTime+"s");
		ThreadTime.sleepTime(1);

		//关闭版本管理子菜单
		login.table_versionClick(false);
		ThreadTime.sleepTime(1);
		test.log(Status.INFO, "点击版本管理，关闭版本管理子菜单");
		report.flush();
		
		//日志管理的子菜单
		login.table_logClick(true);
		ThreadTime.sleepTime(1);
		test.log(Status.INFO, "点击日志管理，打开日志管理子菜单");

		//设备运行日志
		watch.start();
		login.table_logRunDeviceClick();
		wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("/html/body/section/div[2]/div/div/div[2]/div/div/div/div/div[2]/div[2]/div/ul/li[1]")));
		double logRunDeviceTime=(double) watch.getTime() / 1000.0;
		watch.reset();
		sum_logRunDeviceTime = sum_logRunDeviceTime+logRunDeviceTime;
		test.log(Status.INFO, "点击设备运行日志");
		test.log(Status.INFO, "设备运行日志,当前URL="+driver.getCurrentUrl()+",loadingTime="+logRunDeviceTime+"s");
		ThreadTime.sleepTime(1);
			
		//设备异常日志
		watch.start();
		login.table_logDeviceExClick();
		wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("/html/body/section/div[2]/div/div/div[2]/div/div/div/div/div[2]/div[2]/div/ul/li[1]")));
		double logDeviceExTime=(double) watch.getTime() / 1000.0;
		watch.reset();
		sum_logDeviceExTime = sum_logDeviceExTime+logDeviceExTime;
		test.log(Status.INFO, "点击设备异常日志");
		test.log(Status.INFO, "设备异常日志,当前URL="+driver.getCurrentUrl()+",loadingTime="+logDeviceExTime+"s");
		ThreadTime.sleepTime(1);
			
		//内容开始日志
		watch.start();
		login.table_startGameClick();
		wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("/html/body/section/div[2]/div/div/div[2]/div/div/div/div/div[2]/div[2]/div/ul/li[1]")));
		double startGameTime=(double) watch.getTime() / 1000.0;
		watch.reset();
		sum_startGameTime = sum_startGameTime+startGameTime;
		test.log(Status.INFO, "点击内容开始日志");
		test.log(Status.INFO, "内容开始日志,当前URL="+driver.getCurrentUrl()+",loadingTime="+startGameTime+"s");
		ThreadTime.sleepTime(1);
			
		//内容结束日志
		watch.start();
		login.table_endaGameClick();
		wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("/html/body/section/div[2]/div/div/div[2]/div/div/div/div/div[2]/div[2]/div/ul/li[1]")));
		double endGameTime=(double) watch.getTime() / 1000.0;
		watch.reset();
		sum_endGameTime = sum_endGameTime+endGameTime;
		test.log(Status.INFO, "点击内容结束日志");
		test.log(Status.INFO, "内容结束日志,当前URL="+driver.getCurrentUrl()+",loadingTime="+endGameTime+"s");
		ThreadTime.sleepTime(1);
		
		//内容时长日志
		watch.start();
		login.table_gameRuntimeClick();
		wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("/html/body/section/div[2]/div/div/div[2]/div/div/div/div/div[2]/div[2]/div/ul/li[1]")));
		double gameRunTime=(double) watch.getTime() / 1000.0;
		watch.reset();
		sum_gameRunTime = sum_gameRunTime+gameRunTime;
		test.log(Status.INFO, "点击内容时长日志");
		test.log(Status.INFO, "内容时长日志,当前URL="+driver.getCurrentUrl()+",loadingTime="+gameRunTime+"s");
		ThreadTime.sleepTime(1);
			
		//内容每局人数日志
		watch.start();
		login.table_gameplaysClick();
		wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("/html/body/section/div[2]/div/div/div[2]/div/div/div/div/div[2]/div[2]/div/ul/li[1]")));
		double gameplaysTime=(double) watch.getTime() / 1000.0;
		watch.reset();
		sum_gameplaysTime = sum_gameplaysTime+gameplaysTime;
		test.log(Status.INFO, "点击内容每局人数日志");
		test.log(Status.INFO, "内容每局人数日志,当前URL="+driver.getCurrentUrl()+",loadingTime="+gameplaysTime+"s");
		ThreadTime.sleepTime(1);
			
		//内容异常日志
		watch.start();
		login.table_gameEXClick();
		wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("/html/body/section/div[2]/div/div/div[2]/div/div/div/div/div[2]/div[2]/div/ul/li[1]")));
		double gameEXTime=(double) watch.getTime() / 1000.0;
		watch.reset();
		sum_gameEXTime = sum_gameEXTime+gameEXTime;
		test.log(Status.INFO, "内容异常日志");
		test.log(Status.INFO, "内容异常日志,当前URL="+driver.getCurrentUrl()+",loadingTime="+gameEXTime+"s");
		ThreadTime.sleepTime(1);
			
		//内容自定义事件日志
		watch.start();
		login.table_gameEventClick();
		wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("/html/body/section/div[2]/div/div/div[2]/div/div/div/div/div[2]/div[2]/div/ul/li[1]")));
		double gameEventTime=(double) watch.getTime() / 1000.0;
		watch.reset();
		sum_gameEventTime = sum_gameEventTime+gameEventTime;
		test.log(Status.INFO, "内容自定义事件日志");
		test.log(Status.INFO, "内容自定义事件日志,当前URL="+driver.getCurrentUrl()+",loadingTime="+gameEventTime+"s");
		ThreadTime.sleepTime(1);
			
		//购买记录
		watch.start();
		login.table_purchaseClick();
		wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("/html/body/section/div[2]/div/div/div[2]/div/div/div/div/div[2]/div[2]/div/ul/li[1]")));
		double purchaseTime=(double) watch.getTime() / 1000.0;
		watch.reset();
		sum_purchaseTime = sum_purchaseTime+purchaseTime;
		test.log(Status.INFO, "点击购买记录");
		test.log(Status.INFO, "购买记录,当前URL="+driver.getCurrentUrl()+",loadingTime="+purchaseTime+"s");
		ThreadTime.sleepTime(1);
			
		//消费记录
		watch.start();
		login.table_consumeClick();
		wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("/html/body/section/div[2]/div/div/div[2]/div/div/div/div/div[2]/div[2]/div/ul/li[1]")));
		double consumeTime=(double) watch.getTime() / 1000.0;
		watch.reset();
		sum_consumeTime = sum_consumeTime+consumeTime;
		test.log(Status.INFO, "点击消费记录");
		test.log(Status.INFO, "内容自定义事件日志,当前URL="+driver.getCurrentUrl()+",loadingTime="+consumeTime+"s");
		ThreadTime.sleepTime(1);
			
		//赠送记录
		watch.start();
		login.table_giveClick();
		wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("/html/body/section/div[2]/div/div/div[2]/div/div/div/div/div[2]/div[2]/div/ul/li[1]")));
		double giveTime=(double) watch.getTime() / 1000.0;
		watch.reset();
		sum_giveTime = sum_giveTime+giveTime;
		test.log(Status.INFO, "点击赠送记录");
		test.log(Status.INFO, "购买记录,当前URL="+driver.getCurrentUrl()+",loadingTime="+giveTime+"s");
		ThreadTime.sleepTime(1);
	
		//关闭日志管理子菜单
		login.table_logClick(false);
		ThreadTime.sleepTime(1);
		test.log(Status.INFO, "点击日志管理，关闭日志管理子菜单");
		report.flush();
		
		//数据管理的子菜单
		login.table_dataClick(true);
		ThreadTime.sleepTime(1);
		test.log(Status.INFO, "点击数据管理，打开数据管理子菜单");

		//城市字典
		watch.start();
		login.table_dictCityClick();
		wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("/html/body/section/div[2]/div/div/div[2]/div/div/div/div/div[2]/div[1]/div[3]/table/tbody/tr/td[2]")));
		double cityTime=(double) watch.getTime() / 1000.0;
		watch.reset();
		sum_cityTime = sum_cityTime+cityTime;
		test.log(Status.INFO, "点击城市字典");
		test.log(Status.INFO, "城市管理,当前URL="+driver.getCurrentUrl()+",loadingTime="+cityTime+"s");
		ThreadTime.sleepTime(1);
			
		//产品类型字典
		watch.start();
		login.table_dictProductClick();
		wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("/html/body/section/div[2]/div/div/div[2]/div/div/div/div/div[2]/div[1]/div[3]/table/tbody/tr[1]/td[2]")));
		double dictProductTime=(double) watch.getTime() / 1000.0;
		watch.reset();
		sum_dictProductTime = sum_dictProductTime+dictProductTime;
		test.log(Status.INFO, "点击产品类型字典");
		test.log(Status.INFO, "产品类型字典,当前URL="+driver.getCurrentUrl()+",loadingTime="+dictProductTime+"s");
		ThreadTime.sleepTime(1);
			
		//版本类型字典
		watch.start();
		login.table_dictVersionClick();
		wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("/html/body/section/div[2]/div/div/div[2]/div/div/div/div/div[2]/div[1]/div[3]/table/tbody/tr[1]/td[2]")));
		double dictVersionTime=(double) watch.getTime() / 1000.0;
		watch.reset();
		sum_dictVersionTime = sum_dictVersionTime+dictVersionTime;
		test.log(Status.INFO, "点击版本类型字典");
		test.log(Status.INFO, "版本类型字典管理,当前URL="+driver.getCurrentUrl()+",loadingTime="+dictVersionTime+"s");
		ThreadTime.sleepTime(1);
		
		//关闭数据管理子菜单
		login.table_dataClick(false);
		ThreadTime.sleepTime(1);
		test.log(Status.INFO, "点击数据管理，关闭数据管理子菜单");
		report.flush();
		
		//退出登陆
		login.exitUsername(2);
		test.log(Status.INFO, "退出登陆");

		long start=System.currentTimeMillis();
		while(!"http://10.168.1.250:9080/#/login".equals(driver.getCurrentUrl())){
			if("http://10.168.1.250:9080/#/login".equals(driver.getCurrentUrl())){
				test.log(Status.INFO, "退出成功");
				test.log(Status.INFO, "当前URL="+driver.getCurrentUrl());
				return;
			}
			if(ThreadTime.timeout(start,10))break;
			ThreadTime.sleepTime(1);
		}
		
		if(browser.contains("10")){
			test.log(Status.INFO, "测试10次，首页加载打开的平均时间："+String.format("%.3f", sum_homepage/10.0)+"s");
			test.log(Status.INFO, "测试10次，登录的平均时间："+String.format("%.3f", sum_login/10.0)+"s");
			test.log(Status.INFO, "测试10次，用户管理打开的平均时间："+String.format("%.3f", sum_userTime/10.0)+"s");
			test.log(Status.INFO, "测试10次，角色管理打开的平均时间："+String.format("%.3f", sum_roleTime/10.0)+"s");
			test.log(Status.INFO, "测试10次，内容管理打开的平均时间："+String.format("%.3f", sum_gameTime/10.0)+"s");
			test.log(Status.INFO, "测试10次，设备管理打开的平均时间："+String.format("%.3f", sum_devicesTime/10.0)+"s");
			test.log(Status.INFO, "测试10次，教室管理打开的平均时间："+String.format("%.3f", sum_deptTime/10.0)+"s");
			test.log(Status.INFO, "测试10次，教室账号管理打开的平均时间："+String.format("%.3f", sum_opuserTime/10.0)+"s");
			test.log(Status.INFO, "测试10次，版本上传打开的平均时间："+String.format("%.3f", sum_upVersion/10.0)+"s");
			test.log(Status.INFO, "测试10次，设备运行日志打开的平均时间："+String.format("%.3f", sum_logRunDeviceTime/10.0)+"s");
			test.log(Status.INFO, "测试10次，设备异常日志打开的平均时间："+String.format("%.3f", sum_logDeviceExTime/10.0)+"s");
			test.log(Status.INFO, "测试10次，内容开始日志打开的平均时间："+String.format("%.3f", sum_startGameTime/10.0)+"s");
			test.log(Status.INFO, "测试10次，内容结束日志打开的平均时间："+String.format("%.3f", sum_endGameTime/10.0)+"s");
			test.log(Status.INFO, "测试10次，内容时长日志打开的平均时间："+String.format("%.3f", sum_gameRunTime/10.0)+"s");
			test.log(Status.INFO, "测试10次，内容每局人数日志打开的平均时间："+String.format("%.3f", sum_gameplaysTime/10.0)+"s");
			test.log(Status.INFO, "测试10次，内容异常日志打开的平均时间："+String.format("%.3f", sum_gameEXTime/10.0)+"s");
			test.log(Status.INFO, "测试10次，内容自定义事件日志打开的平均时间："+String.format("%.3f", sum_gameEventTime/10.0)+"s");
			test.log(Status.INFO, "测试10次，购买记录日志打开的平均时间："+String.format("%.3f", sum_purchaseTime/10.0)+"s");
			test.log(Status.INFO, "测试10次，消费记录日志打开的平均时间："+String.format("%.3f", sum_consumeTime/10.0)+"s");
			test.log(Status.INFO, "测试10次，赠送记录日志打开的平均时间："+String.format("%.3f", sum_giveTime/10.0)+"s");
			test.log(Status.INFO, "测试10次，城市字典打开的平均时间："+String.format("%.3f", sum_cityTime/10.0)+"s");
			test.log(Status.INFO, "测试10次，产品类型字典打开的平均时间："+String.format("%.3f", sum_dictProductTime/10.0)+"s");
			test.log(Status.INFO, "测试10次，版本类型字典打开的平均时间："+String.format("%.3f", sum_dictVersionTime/10.0)+"s");
		}
		report.flush();
	}

	@BeforeMethod(description = "跳转到-首页")
	public void beforeMethod() {
//		ThreadTime.sleepTime(1);
//		driver.get(url);
//		ThreadTime.sleepTime(1);
	}

	@AfterMethod(description = "记录测试结果")
	public void afterMethod(ITestResult result) {
		String desc = result.getMethod().getDescription();
		String methodName = result.getMethod().getMethodName();
		switch (result.getStatus()) {
		case ITestResult.FAILURE:
			test.log(Status.FAIL, methodName + " " + desc +" --Run Result Fail");
			break;
		case ITestResult.SKIP:
			test.log(Status.SKIP, methodName + " " + desc + " --Run Result skip");
			break;
		case ITestResult.SUCCESS:
			test.log(Status.PASS, methodName + " " + desc + " --Run Result pass");
			break;
		}
		report.flush();
	}

	@BeforeClass(description = "初始化WebDriver")
	@Parameters({ "browser" })
	public void beforeClass(String browser) {
		if(browser.contains("firefox")){
			test = report.createTest(browser + " Test");
			driver = getWebDriver.setInternetIE("firefox");
			test.log(Status.INFO, "start browser=" + browser);
		}else if(browser.contains("chrome")){
			test = report.createTest(browser + " Test");
			driver = getWebDriver.setInternetIE("chrome");
			test.log(Status.INFO, "start browser=" + browser);
		}else if(browser.contains("edge")){
			test = report.createTest(browser + " Test");
			driver = getWebDriver.setInternetIE("edge");
			test.log(Status.INFO, "start browser=" + browser);
		}else if(browser.contains("ie")){
			test = report.createTest(browser + " Test");
			driver = getWebDriver.setInternetIE("ie");
			test.log(Status.INFO, "start browser=" + browser);
		}
		//driver = new EventFiringWebDriver(getWebDriver.setInternetIE(browser)).register(new eventsListener());
		//driver.get(url);
		//test.log(Status.INFO, "get URL=" + url);

		driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
		driver.manage().window().maximize();
		test.log(Status.INFO, "browser set max...");
		
		login = new login(test, driver);
		Operate = new linkOperate(test, driver);
		report.flush();
	}

	@AfterClass(description = "关闭浏览器")
	public void afterClass() {
		ThreadTime.sleepTime(2);
		test.log(Status.INFO, "Close IE");
		report.flush();
		ThreadTime.sleepTime(1);
		driver.quit();
	}
}
